﻿// --------------------------------------------------------------------------------------------------------------------
// <copyright file="TypeConverter.cs" company="">
//   
// </copyright>
// <summary>
//   The ticker converter.
// </summary>
// --------------------------------------------------------------------------------------------------------------------


using System;
using System.ComponentModel;
using System.Globalization;
using Systemathics.FrameWork;

namespace Systemathics.UserControls
{
    internal class TickerConverter : ExpandableObjectConverter
    {
        public override object ConvertTo(ITypeDescriptorContext context, CultureInfo culture, object value, Type destType)
        {
            if (destType == typeof (string) && value is Ticker)
            {
                var ticker = (Ticker) value;
                return ticker.Provider; // ticker.Provider + ", " + ticker.Ric;
            }

            return base.ConvertTo(context, culture, value, destType);
        }
    }
    internal class OstConverter : ExpandableObjectConverter
    {
        public override object ConvertTo(ITypeDescriptorContext context, CultureInfo culture, object value, Type destType)
        {
            if (destType == typeof (DateTime) && value is Ost)
            {
                var ost = (Ost) value;
                return ost.Date;
            }

            return base.ConvertTo(context, culture, value, destType);
        }
    }
}